package com.cn.wanxi.controller;

import com.cn.wanxi.Result.Result;
import com.cn.wanxi.entity.User;
import com.cn.wanxi.service.UserService;
import com.cn.wanxi.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class LoginController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(User user, HttpServletRequest req) {
        String sessionCode = (String) req.getSession().getAttribute("vCode");
        user.setSessionCode(sessionCode);
        return userService.login(user);
    }
}
